#include "QtUI/RequirementInformationWidget.qth"
#include "QtUI/RequirementInformationWidget.moh"
#include "QtGuiEx/RichTextEditor.qth"
#include "QtGuiEx/RichTextEditorBar.qth"
#include <QtGui/QGridLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QLabel>


namespace QtUI
{

RequirementInformationWidget::RequirementInformationWidget( QWidget* pParent)
	: QWidget( pParent)
{
	QGridLayout* pLayout = new QGridLayout;
	this->setLayout( pLayout);

	pNameEditor_ = new QLineEdit;
	QLabel* pLabel = new QLabel( pNameEditor_);
	pLabel->setText( tr( "&Name", "Requirement name editor label"));
	pLayout->addWidget( pLabel, 0, 0);
	pLayout->addWidget( pNameEditor_, 0, 1);

	QtGuiEx::RichTextEditorBar* pToolBar = new QtGuiEx::RichTextEditorBar;
	pStatementEditor_ = new QtGuiEx::RichTextEditor;
	pStatementEditor_->connectToBar( pToolBar);
	pLabel = new QLabel( pStatementEditor_);
	pLabel->setText( tr( "&Description", "Description editor label"));
	pLayout->addWidget( pToolBar, 1, 1);
	pLayout->addWidget( pLabel, 2, 0);
	pLayout->setAlignment( pLabel, Qt::AlignLeft | Qt::AlignTop);
	pLayout->addWidget( pStatementEditor_, 2, 1);
}

// ---------------------------------------------------------------------------------------------------------------------

QString RequirementInformationWidget::requirementName() const
{
	return pNameEditor_->text().trimmed();
}

// ---------------------------------------------------------------------------------------------------------------------

void RequirementInformationWidget::setRequirementName( const QString& newName)
{
	pNameEditor_->setText( newName);
}

// ---------------------------------------------------------------------------------------------------------------------

QString RequirementInformationWidget::requirementStatement() const
{
	return pStatementEditor_->toHtml();
}

// ---------------------------------------------------------------------------------------------------------------------

void RequirementInformationWidget::setRequirementStatement( const QString& newStatement)
{
	pStatementEditor_->setHtml( newStatement);
}
	
} // namespace QtUI
